package com.roowoo.plateform.controller;

import com.roowoo.plateform.feign.FeignUserService;
import com.roowoo.plateform.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/***
 * @project: spring-cloud
 * @package: com.roowoo.plateform.controller
 * @description:
 * @author: kyrie
 * @mail: 18654169290@163.com
 * @createDate: 2022/3/17 10:40
 */
@RestController
@Slf4j
public class OrderController {

    @Resource
    private FeignUserService feignUserService;

    @Resource
    private OrderService orderService;

    @GetMapping("/feignHystrix/{userId}")
    public String feignHystrix(@PathVariable("userId") String userId) {
        String userInfo = feignUserService.getUserInfo(userId);
        log.info("用户信息为: {}", userInfo);
        return userInfo;
    }

    @GetMapping("/restTemplateHystrix/{userId}")
    public String restTemplateHystrix(@PathVariable("userId") String userId) {
        String userInfo = orderService.getUserInfo(userId);
        log.info("用户信息为: {}", userInfo);
        return userInfo;
    }
}
